package com.wan.util.number;

/**
 * [-128,127]范围内循环递增
 * @author wwh
 * @date 2022/6/20 19:58
 */
public class ByteIncrement {

    private byte current;

    public ByteIncrement(byte current) {
        this.current = current;
    }

    public synchronized byte next(){
        if(current == Byte.MAX_VALUE) {
            current = Byte.MIN_VALUE;
        }
        return current++;
    }

    @Override
    public String toString() {
        return String.valueOf(current);
    }
}
